﻿using System;
using System.Linq;
using System.ServiceProcess;
using Ayatta.Contract.Component;

namespace Ayatta.Service.Product.Index
{
    public class Program
    {
        public static readonly string ServiceName = "Ayatta.Service.Product.Index";
        public static readonly string Description = "商品索引服务";
        /// <summary>
        /// 应用程序的主入口点
        /// </summary>
        public static void Main(string[] args)
        {
            Run(true);
        }

        private static void Run(bool asService = false)
        {
            if (asService)
            {
                var servicesToRun = new ServiceBase[]
                {
                    new WindowsService()
                };
                ServiceBase.Run(servicesToRun);
            }
            else
            {
                var s = new ProductIndexService();
                //s.Index();
                var param = new ProductQueryParam();
                param.Keyword = "Chloe";
                param.Highlight = true;
                var r = s.Search(param);
                Console.WriteLine(r.Data.Count());
                Console.Read();
            }
        }
    }
}
